package com.woniuxy.microgoodsserver.auctionmag.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microgoodsserver.auctionmag.mapper.GoodsBrandMapper;
import com.woniuxy.microgoodsserver.auctionmag.service.GoodsBrandService;
import com.woniuxy.microgoodsserver.auctionmag.service.GoodsService;
import com.woniuxy.microgoodsserver.bean.GoodsBean;
import com.woniuxy.microgoodsserver.bean.GoodsBrandBean;
import com.woniuxy.microgoodsserver.bean.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsBrandServiceImpl implements GoodsBrandService {

    @Resource
    GoodsBrandMapper goodsBrandMapper;

    @Override
    public PageInfo<GoodsBrandBean> brandFindAll(PageRequest pageRequest, GoodsBrandBean goodsBrandBean) {
       return PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getLimit()).
                doSelectPageInfo(()->goodsBrandMapper.brandFindAll(pageRequest,goodsBrandBean));
    }

    @Override
    public GoodsBrandBean brandFindById(int id) {

        GoodsBrandBean goodsBrandBean = goodsBrandMapper.brandFindAllById(id);

        return goodsBrandBean;
    }

    @Override
    public int savaBrand(GoodsBrandBean goodsBrandBean) {
        int a = goodsBrandMapper.SaveBrand(goodsBrandBean);
        return a;
    }

    @Override
    public int updateBrand(GoodsBrandBean goodsBrandBean) {

        int a = goodsBrandMapper.updateGoodBrandBean(goodsBrandBean);

        return a;
    }


}
